# U-boot RC built for rk3399, can be upstreamed to alpine soon when 2020.04 is released

pkgname=u-boot-rockpro64
pkgver=2020.04
pkgrel=1
pkgdesc="u-boot bootloader for the rk3399"
url="https://gitlab.com/pine64-org/u-boot"
arch="aarch64"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
	ISC LGPL-2.0-only LGPL-2.1-only X11"
makedepends="$depends_dev bc dtc python3-dev swig bison flex openssl-dev arm-trusted-firmware-rk3399"
options="!check"
source="
	ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver//_/-}.tar.bz2
	rk3399-power-led.patch
	update-u-boot
	"
builddir="$srcdir"/u-boot-${pkgver//_/-}

build() {
	touch include/config.h
	LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
	LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h

	export BL31="/usr/share/arm-trusted-firmware-rk3399/bl31.elf"
	export BUILD_DIR="$builddir"/build
	mkdir -p "$BUILD_DIR"
	make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm rockpro64-rk3399_defconfig
	make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm all
}

package() {
	install -D -m644 build/u-boot-rockchip.bin \
		"$pkgdir"/usr/share/u-boot/pine64-rockpro64/u-boot-rockchip.bin
	install -D -m755 "$srcdir"/update-u-boot "$pkgdir"/usr/sbin/update-u-boot
}


sha512sums="e04fe54883149123730605b084324ac0d1d72ce6913467bbe587a5a2675bcf7bb393405d9a446dc0c64ba42abc1e862ae5a132e9e51aa7390e2e9fce045af8d8  u-boot-2020.04.tar.bz2
4495dbaceac1cc42b3506dda81e0920f8eca19e11e0d717637dba6e4623e95cd4c3c94e7fc3aa8f3cbfe5fcaf0c0c109d1699eb7f278a69fa8e209c7cd6e4c02  rk3399-power-led.patch
3fb94ae63b122b85d8a4822bbcfc4e4d12beff1c752dd93e45dc49458dc5ccc5483b1ff3ac8cd628859b9d19fe95aa6b2d050df557ba2715737fa8322833ef6a  update-u-boot"
